﻿using System;
using System.Collections.Generic;
using System.Linq;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;

namespace Sample.Novel.Domain.Books.Entites
{
    public class Volume
        : Entity<Guid>, IHasCreationTime
    {
        public virtual Book Book { get; set; }  
        public Guid BookId { get; set; } 
        public string Title { get; set; }
        public string Description { get; set; } 
        public virtual List<Chapter> Chapters { get; set; }

        public DateTime CreationTime {get;set;}

        protected Volume() { 
            
        }

        public Volume(string title, string decription) { 
            this.Title = title;
            this.Description = decription;
        }

        public void AddChapter(Chapter chapter)
        {
            if (Chapters.Any(c => c.Title == chapter.Title)) {
                return;
            }
            this.Chapters.Add(chapter);
        }
    }
}